﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication5
{
    public partial class Register : System.Web.UI.Page
    {
        private SqlHelper sqlHelper = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = Username.Text;
            string password = Password.Text;
            string email = Email.Text;
            string gender = Male.Checked ? "1" : "0";

            string sql = "insert into StudentInfo (stu_name,gender,email,[password]) values(@name,@gender,@email,@password)";
            SqlParameter[] pars = {
                new SqlParameter("@name",name),
                new SqlParameter("@password",password),
                new SqlParameter("@email",email),
                new SqlParameter("@gender",gender)
            };

            if (sqlHelper.Execute(sql, pars))
            {
                Literal1.Text = "注册成功,<a href='login.aspx'> 去登陆</a>";

            }
            else {
                Literal1.Text = "注册失败";
            }


        }
    }
}